Sealed classes: Some times we want to prevent the class from inheritance. To prevent a class from being inherited, precede its declaration with sealed.
Syntax:
sealed class classsname
{
Body of the class
}
Program on sealed classes
using System;
sealed class rect
{
int l, b;
public void get(int x, int y)
{
l = x;
b = y;
}
public void put()
{
Console.WriteLine("Rectangle" + (l * b));
}
}
class vision
{
public static void Main(String[] args)
{
rect r = new rect();
r.get(4, 3);
r.put();
}
}
Note: Rect class is not possible to inherit to any other class because it is sealed